package com.example.demofdfs.test2;

import redis.clients.jedis.Jedis;

public class RedisTest {
	
	public static void main(String[] args) {
		long time = System.currentTimeMillis();
		System.out.println(keys());
		long end = System.currentTimeMillis();
		System.out.println(end - time);
	}
	
	public static Object keys() {
		Jedis jedis = JedisPool.jedis();
		try {
			return jedis.keys("*");
		} finally {
			// TODO: handle finally clause
			jedis.close();
		}
	}
	
	public static Object get(String key) {
		Jedis jedis = JedisPool.jedis();
		try {
			//		for(int i = 0; i < 100000; i++)
			//			System.out.println(jedis.set("key-" + i, "value-" + i));
			return jedis.get(key);
		} finally {
			// TODO: handle finally clause
			jedis.close();
		}
	}
	
	private static class JedisPool {
		public static Jedis jedis() {
			return new Jedis("192.168.121.163", 6379);
		}
	}
}
